/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rest.jbpm.services;

import java.util.regex.Pattern;

/**
 *
 * @author jump
 */
public class DNC14N {

    /**
     * пробелы до и после = и ,
     */
    private final static Pattern pat1 = Pattern.compile("\\s*([,=])\\s*");

    private final static Pattern pat2 = Pattern.compile("\\s*\\n\\r*\\s*");

    public static String c14n(String dn) {

        return pat2.matcher(pat1.matcher(dn).replaceAll("$1")).replaceAll("")
                .replace("cn", "CN").replace("dc", "DC").replace("uid", "UID");

    }

}
